FeatureGetCost Example

InstallShield 2019 ยป InstallScript Language Reference

/*--------------------------------------------------------------*\

*

* InstallShield Example Script

*

* Demonstrates the FeatureGetCost function.

*

* This example script displays a dialog that shows the user

* the size of each top-level feature that they selected.

*

*  Comments:  To run this example script, create a project (or

*             insert into a project) with several features

*             and/or subfeatures with components containing

*             files.    

*

\*--------------------------------------------------------------*/

 

#include "Ifx.h"

    

function OnBegin()  

    string svDir, svFeature, svFeatureInfo;

    LIST listFeatures, listFeatureInfo;

    number nListGetString, nvRequiredSpace;

begin  

    svDir = TARGETDIR;

    SdFeatureTree ("", "", svDir, "", 1);

 

    listFeatures = ListCreate ( STRINGLIST );

    FeatureListItems ( MEDIA, "", listFeatures );

    nListGetString = ListGetFirstString ( listFeatures, svFeature );

    listFeatureInfo = ListCreate ( STRINGLIST );

    while nListGetString=0

        FeatureGetCost ( MEDIA, svFeature, svDir, nvRequiredSpace );

        Sprintf ( svFeatureInfo, "Selected feature %s has a size of %ld KB.\n",

            svFeature, nvRequiredSpace );

        ListAddString ( listFeatureInfo, svFeatureInfo, AFTER );

        nListGetString = ListGetNextString ( listFeatures, svFeature );

    endwhile;

    ListDestroy ( listFeatures );

 

    SdShowInfoList ( "", "", listFeatureInfo );

    ListDestroy ( listFeatureInfo );

end;